package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPlatformPromise;
import com.ruoyi.zsyh.service.IZsyhPlatformPromiseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务承诺标签Controller
 * 
 * @author yuexl
 * @date 2021-12-16
 */
@Controller
@RequestMapping("/zsyh/promise")
public class ZsyhPlatformPromiseController extends BaseController
{
    private String prefix = "zsyh/promise";

    @Autowired
    private IZsyhPlatformPromiseService zsyhPlatformPromiseService;

    @RequiresPermissions("zsyh:promise:view")
    @GetMapping()
    public String promise()
    {
        return prefix + "/promise";
    }

    /**
     * 查询服务承诺标签列表
     */
    @RequiresPermissions("zsyh:promise:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPlatformPromise zsyhPlatformPromise)
    {
        startPage();
        List<ZsyhPlatformPromise> list = zsyhPlatformPromiseService.selectZsyhPlatformPromiseList(zsyhPlatformPromise);
        return getDataTable(list);
    }

    /**
     * 导出服务承诺标签列表
     */
    @RequiresPermissions("zsyh:promise:export")
    @Log(title = "服务承诺标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPlatformPromise zsyhPlatformPromise)
    {
        List<ZsyhPlatformPromise> list = zsyhPlatformPromiseService.selectZsyhPlatformPromiseList(zsyhPlatformPromise);
        ExcelUtil<ZsyhPlatformPromise> util = new ExcelUtil<ZsyhPlatformPromise>(ZsyhPlatformPromise.class);
        return util.exportExcel(list, "服务承诺标签数据");
    }

    /**
     * 新增服务承诺标签
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存服务承诺标签
     */
    @RequiresPermissions("zsyh:promise:add")
    @Log(title = "服务承诺标签", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPlatformPromise zsyhPlatformPromise)
    {
        return toAjax(zsyhPlatformPromiseService.insertZsyhPlatformPromise(zsyhPlatformPromise));
    }

    /**
     * 修改服务承诺标签
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhPlatformPromise zsyhPlatformPromise = zsyhPlatformPromiseService.selectZsyhPlatformPromiseById(id);
        mmap.put("zsyhPlatformPromise", zsyhPlatformPromise);
        return prefix + "/edit";
    }

    /**
     * 修改保存服务承诺标签
     */
    @RequiresPermissions("zsyh:promise:edit")
    @Log(title = "服务承诺标签", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPlatformPromise zsyhPlatformPromise)
    {
        return toAjax(zsyhPlatformPromiseService.updateZsyhPlatformPromise(zsyhPlatformPromise));
    }

    /**
     * 删除服务承诺标签
     */
    @RequiresPermissions("zsyh:promise:remove")
    @Log(title = "服务承诺标签", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPlatformPromiseService.deleteZsyhPlatformPromiseByIds(ids));
    }
}
